import request from '@/utils/request'

// 获取图书信息
export const getBookList = () => {
  return request.get('/book/list')
}

// 新增图书
export const addBook = (name, categoryName, author, price, quantity, description) => {
  return request.post('/book', {
    name,
    categoryName,
    author,
    price,
    quantity,
    description
  })
}

// 根据id删除图书
export const deleteBookById = (id) => {
  return request.delete('/book/' + id)
}

// 批量删除图书

// 修改图书
export const updateById = (id, name, categoryName, author, price, quantity, description) => {
  return request.put('/book', {
    id,
    name,
    categoryName,
    author,
    price,
    quantity,
    description
  })
}

// 根据id查询图书
export const getById = (id) => {
  return request.get('/book/' + id)
}

// 图书条件分页查询
export const bookListPage = (page, pageSize, name, categoryName, begin, end) => {
  console.log(page, pageSize, name, categoryName, begin, end)
  return request.get('/book/page', {
    params: {
      page,
      pageSize,
      name,
      categoryName,
      begin,
      end
    }
  })
}

export const testTime = (begin, end) => {
  return request.get('/book/time', {
    params: {
      begin,
      end
    }
  })
}
